package cn.com.zero.common.message.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xiongxj
 * @version 1.0.0
 * @Description 消息的配置内容
 * @createTime 2023/2/28 17:00
 */
@Configuration
@Validated
@ConfigurationProperties(prefix = "message", ignoreUnknownFields = false)
public class MessageProperties {

    /**
     * 短信通道，即发送短信的提供方
     */
    private String channel = "test";

    /**
     * 每天同一个IP最多发送短信数量 最小值10 最大值200
     */
    private Integer maxSendNumByIp = 100;

    /**
     * 每天同一个手机号最多发送短信数量 最小值3 最大值50
     */
    private Integer maxSendNumByPhone = 10;

    /**
     * 手机号白名单；白名单中的手机号发送不限制次数（列入运维人员手机号可加入白名单，用于接收系统故障信息）
     */
    private List<String> phoneWhiteList = new ArrayList<>();

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public Integer getMaxSendNumByIp() {
        return maxSendNumByIp;
    }

    public void setMaxSendNumByIp(Integer maxSendNumByIp) {
        if (maxSendNumByIp < 10 || maxSendNumByIp > 200) {
            return;
        }
        this.maxSendNumByIp = maxSendNumByIp;
    }

    public Integer getMaxSendNumByPhone() {
        return maxSendNumByPhone;
    }

    public void setMaxSendNumByPhone(Integer maxSendNumByPhone) {
        if (maxSendNumByPhone < 3 || maxSendNumByPhone > 50) {
            return;
        }
        this.maxSendNumByPhone = maxSendNumByPhone;
    }

    public List<String> getPhoneWhiteList() {
        return phoneWhiteList;
    }

    public void setPhoneWhiteList(List<String> phoneWhiteList) {
        this.phoneWhiteList = phoneWhiteList;
    }
}
